package xyz.weizhi.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.weizhi.tanhua.dubbo.mapper.BlackListMapper;
import xyz.weizhi.tanhua.dubbo.mapper.UserInfoMapper;
import xyz.weizhi.tanhua.model.domain.BlackList;
import xyz.weizhi.tanhua.model.domain.UserInfo;

/**
 * @Author milian
 * @Date 2021/10/24 0024 16:19
 */
@DubboService
public class BlackListApiImpl extends ServiceImpl<BlackListMapper, BlackList> implements BlackListApi{
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private BlackListMapper blackListMapper;
    @Override
    public IPage findByUserId(Long userId, int page, int pagesize) {
        Page pages = new Page(page, pagesize);
        QueryWrapper<UserInfo> qw = new QueryWrapper<>();
        qw.eq("id", userId);
        return userInfoMapper.selectMapsPage(pages,qw);
    }

    @Override
    public void delete(Long userId, Long blackUserId) {
        QueryWrapper<BlackList> qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        qw.eq("black_user_id",blackUserId);
        blackListMapper.delete(qw);
    }
}
